

import task from "../../../models/dict/task.js"  //任务字典模块
import array from "../../../models/comm/array.js"  //数组操作模块
import py from '../../../models/comm/webPy';
import axios from 'axios';
import Vue from 'vue'
import flow from '../../../models/dict/flow';
export default {


    data: function () {


        return {
            taskClassArray: task.classArray(),
            pickerOptions2: {
                shortcuts: [{
                    text: '最近一周',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近一个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近三个月',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                        picker.$emit('pick', [start, end]);
                    }
                }]
            }



        }
    },
    props: {

        currObj: {},
        currNodeObj: {
        },

        ShowSaveNode: {

        },
        editLoading: {}

    },
    methods: {


        querySearchMember: async function (query, cb) {
            var data = {
                "$or": [
                    { name: { $regex: query } },
                    { namePy: { $regex: await py.firstLetter(query) } }
                ]
            }
            //  console.log(JSON.stringify(data));
            if (query !== '') {
                this.loading = true;
                axios.post("/a", {
                    class: "member",
                    para: "getMemberList",
                    j: {
                        data: data

                    }

                }).then((res) => {

                    this.loading = false;

                    var list = res.data.list;

                    list.forEach(function (member) {
                        member.value = member.name;

                    }, this);
                    cb(list)

                });

            }
        },
        selManager: function (params) {


            var b = false;
            this.currNodeObj.managers.forEach(function (manager) {
                if (params._id == manager._id) {

                    b = true;
                    return false;
                }

            }, this);
            if (!b) {
                this.currNodeObj.managers.push({

                    name: params.name,
                    _id: params._id
                });


                this.$emit("addNodeMember", params, "managers")



            }

            //     console.log(JSON.stringify(this.currNodeObj.managers));

        },
        selMember: function (params) {


            var b = false;
            this.currNodeObj.members.forEach(function (member) {
                if (params._id == member._id) {

                    b = true;
                    return false;
                }

            }, this);
            if (!b) {
                this.currNodeObj.members.push({

                    name: params.name,
                    _id: params._id
                });

            }
            this.$emit("addNodeMember", params, "members")

            //     console.log(JSON.stringify(this.currNodeObj.managers));

        }

        ,
        handleClose: function (tag, tags, type) {

            tags.splice(tags.indexOf(tag), 1);



            this.$emit("removeNodeMember", tag, type)
        },
        beforeEnter: function () {
            console.log('beforeEnter');
        }




    },
    mounted() {

        //   this.fmtNodeObj();
        // this.fmtCurrObj();
        console.log('mounted');
    },


    created: function () {
        console.log('chuangjian');
    },
    beforeCreate: function () {
        console.log('beforeCreate ');
    }

}